package com.itema.mapper;

import com.itema.pojo.Clazz;
import com.itema.pojo.ClazzQueryParam;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface ClazzMapper {

    /**
     * 根据id查询班级信息
     */
    @Select("select * from clazz where id = #{id}")
    Clazz findById(Integer id);


    /**
     * 分页查询班级信息
     */
    List<Clazz> list(ClazzQueryParam clazzQueryParam);

    /**
     * 添加班级信息
     */
    @Insert("insert into clazz VALUES (null,#{name},#{room},#{beginDate},#{endDate},#{masterId}, #{subject},#{createTime},#{updateTime})")
    void insert(Clazz clazz);

    /**
     * 修改班级信息
     */
    @Insert("update clazz set name = #{name},room = #{room},begin_date = #{beginDate},end_date = #{endDate},master_id = #{masterId},subject = #{subject},update_time = #{updateTime} where id = #{id}")
    void update(Clazz clazz);

    /**
     * 删除班级信息
     */
    @Delete("delete from clazz where id = #{id}")
    void deleteById(Integer id);

    /**
     * 查询所有班级信息
     */
    @Select("select * from clazz")
    List<Clazz> findAll();
}
